package com.mc.utils;

import java.io.IOException;

import org.springframework.beans.factory.annotation.Autowired;

public class WebFetch {
	public void fetch( String cdm){
		    System.out.println("**********************************************");
		    System.out.println("执行网页抓取……");
			try {
				Process pro=null;
				Runtime run = Runtime.getRuntime(); 
				pro=run.exec(cdm);
				StreamGobbler errorGobbler = new StreamGobbler(pro.getErrorStream(), "ERROR"); 
			    // kick off stderr  
			    errorGobbler.start();  
			    StreamGobbler outGobbler = new StreamGobbler(pro.getInputStream(), "STDOUT");  
			    // kick off stdout  
			    outGobbler.start();  
			    pro.waitFor();
				System.out.println("网页抓取完毕。");
				System.out.println("**********************************************");
				
			} catch (IOException | InterruptedException e) {
				System.out.println("定时任务执行异常");
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
	}
 
}
